import java.awt.*;
import javax.swing.*;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;

public class Match implements ActionListener {
        JFrame window = new JFrame("德州扑克 - 对局");
        JButton button_弃牌 = new JButton("弃牌");
        JButton button_跟注 = new JButton("跟注");
        JButton button_加注 = new JButton("加注");
        JTextField textField_加注 = new JTextField();
        JButton button_继续 = new JButton("继续");
        JLabel PublicCard = new JLabel("公共牌：");
        JLabel Pool = new JLabel("奖池金额：");
        JLabel Pool_i = new JLabel("$---");
        JLabel YourMoney = new JLabel("您的剩余金额：");
        JLabel YourMoney_i = new JLabel("$---");
        JLabel YourKicker = new JLabel("您的起脚牌：");
        JLabel YourType = new JLabel();
        JLabel PlayerX = new JLabel("玩家X：");
        JLabel PlayerX_i = new JLabel("playerX");
        JLabel PlayerY = new JLabel("玩家Y：");
        JLabel PlayerY_i = new JLabel("playerY");
        JLabel PlayerZ = new JLabel("玩家Z：");
        JLabel PlayerZ_i = new JLabel("playerZ");
        JLabel XMoney = new JLabel("该玩家的剩余金额：");
        JLabel XMoney_i = new JLabel("$---");
        JLabel l_X玩家牌型 = new JLabel();
        JLabel YMoney = new JLabel("该玩家的剩余金额：");
        JLabel YMoney_i = new JLabel("$---");
        JLabel l_Y玩家牌型 = new JLabel();
        JLabel ZMoney = new JLabel("该玩家的剩余金额：");
        JLabel ZMoney_i = new JLabel("$---");
        JLabel l_Z玩家牌型 = new JLabel();
        JLabel l_已投注额 = new JLabel("已投注额：");
        JLabel l_已投money = new JLabel("$---");
        JLabel l_应投注额 = new JLabel("应投注额：");
        JLabel l_应投money = new JLabel("$---");
        JLabel l_当前轮数 = new JLabel("当前轮数：");
        JLabel l_当前轮数value = new JLabel();
        JLabel l_备用 = new JLabel("备用");
        ImageIcon PublicCard_1 = new ImageIcon(".\\image\\poker\\" + "00" + ".png");
        ImageIcon PublicCard_2 = new ImageIcon(".\\image\\poker\\" + "00" + ".png");
        ImageIcon PublicCard_3 = new ImageIcon(".\\image\\poker\\" + "00" + ".png");
        ImageIcon PublicCard_4 = new ImageIcon(".\\image\\poker\\" + "00" + ".png");
        ImageIcon PublicCard_5 = new ImageIcon(".\\image\\poker\\" + "00" + ".png");
        ImageIcon kicker_1 = new ImageIcon(".\\image\\poker\\" + "00" + ".png");
        ImageIcon kicker_2 = new ImageIcon(".\\image\\poker\\" + "00" + ".png");
        ImageIcon PXCard_1 = new ImageIcon(".\\image\\poker\\" + "00" + ".png");
        ImageIcon PXCard_2 = new ImageIcon(".\\image\\poker\\" + "00" + ".png");
        ImageIcon PYCard_1 = new ImageIcon(".\\image\\poker\\" + "00" + ".png");
        ImageIcon PYCard_2 = new ImageIcon(".\\image\\poker\\" + "00" + ".png");
        ImageIcon PZCard_1 = new ImageIcon(".\\image\\poker\\" + "00" + ".png");
        ImageIcon PZCard_2 = new ImageIcon(".\\image\\poker\\" + "00" + ".png");
        ImageIcon bg = new ImageIcon(".\\image\\bg.png");
        JLabel publicC_1 = new JLabel(PublicCard_1);
        JLabel publicC_2 = new JLabel(PublicCard_2);
        JLabel publicC_3 = new JLabel(PublicCard_3);
        JLabel publicC_4 = new JLabel(PublicCard_4);
        JLabel publicC_5 = new JLabel(PublicCard_5);
        JLabel kickerC_1 = new JLabel(kicker_1);
        JLabel kickerC_2 = new JLabel(kicker_2);
        JLabel jl_pXCard_1 = new JLabel(PXCard_1);
        JLabel jl_pXCard_2 = new JLabel(PXCard_2);
        JLabel jl_pYCard_1 = new JLabel(PYCard_1);
        JLabel jl_pYCard_2 = new JLabel(PYCard_2);
        JLabel jl_pZCard_1 = new JLabel(PZCard_1);
        JLabel jl_pZCard_2 = new JLabel(PZCard_2);
        JLabel jl_bg_image = new JLabel(bg);

        int maxAdd = 0;

        public static void main(String[] args) {
                new Match();
        }

        public Match() {
                button_弃牌.setEnabled(false);
                button_加注.setEnabled(false);
                button_跟注.setEnabled(false);
                button_继续.setEnabled(false);
                textField_加注.setEnabled(false);
                textField_加注.setMaximumSize(new Dimension(110, 20));

                button_弃牌.addActionListener(this);
                button_加注.addActionListener(this);
                button_跟注.addActionListener(this);
                button_继续.addActionListener(this);

                JPanel AllPanel = new JPanel();
                JPanel panelA = new JPanel();
                JPanel panelB = new JPanel();
                JPanel panelC = new JPanel();
                JPanel panelD = new JPanel();
                JPanel panel_a1 = new JPanel();
                JPanel panel_a2 = new JPanel();
                JPanel panel_a3 = new JPanel();
                JPanel panel_a4 = new JPanel();
                JPanel panel_c1 = new JPanel();
                JPanel panel_c2 = new JPanel();
                JPanel panel_c3 = new JPanel();
                Font f1 = new Font("微软雅黑", Font.BOLD, 40);
                button_加注.setFont(f1);
                button_弃牌.setFont(f1);
                button_跟注.setFont(f1);
                button_继续.setFont(f1);
                window.setBounds(520, 100, 1440, 810);
                window.setVisible(true);
                window.setResizable(false);
                window.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

                /* 设置panel_a1的布局 */
                GroupLayout layout_a1 = new GroupLayout(panel_a1);
                panel_a1.setLayout(layout_a1);
                layout_a1.setAutoCreateContainerGaps(true);
                layout_a1.setAutoCreateGaps(true);
                // 水平组
                GroupLayout.ParallelGroup hParallelGroup = layout_a1.createParallelGroup().addComponent(PublicCard);
                GroupLayout.SequentialGroup hSequentialGroup = layout_a1.createSequentialGroup().addComponent(publicC_1)
                                .addComponent(publicC_2).addComponent(publicC_3).addComponent(publicC_4)
                                .addComponent(publicC_5);
                GroupLayout.ParallelGroup hGroup = layout_a1.createParallelGroup().addGroup(hParallelGroup)
                                .addGroup(hSequentialGroup);
                layout_a1.setHorizontalGroup(hGroup);
                // 垂直组
                GroupLayout.ParallelGroup vParallelGroup = layout_a1.createParallelGroup().addComponent(PublicCard);
                GroupLayout.ParallelGroup vParallelGroup2 = layout_a1.createParallelGroup().addComponent(publicC_1)
                                .addComponent(publicC_2).addComponent(publicC_3).addComponent(publicC_4)
                                .addComponent(publicC_5);
                GroupLayout.SequentialGroup vGroup = layout_a1.createSequentialGroup().addGroup(vParallelGroup)
                                .addGroup(vParallelGroup2);
                layout_a1.setVerticalGroup(vGroup);

                /* 设置panel_a2的布局 */
                GroupLayout layout_a2 = new GroupLayout(panel_a2);
                panel_a2.setLayout(layout_a2);
                layout_a2.setAutoCreateContainerGaps(true);
                layout_a2.setAutoCreateGaps(true);
                // 水平组
                GroupLayout.ParallelGroup hParallelGroup2 = layout_a2.createParallelGroup().addComponent(Pool)
                                .addComponent(Pool_i);
                GroupLayout.ParallelGroup hParallelGroup3 = layout_a2.createParallelGroup().addComponent(l_当前轮数)
                                .addComponent(l_当前轮数value);
                GroupLayout.ParallelGroup hParallelGroup4 = layout_a2.createParallelGroup().addComponent(l_备用);
                GroupLayout.SequentialGroup hGroup2 = layout_a2.createSequentialGroup().addGroup(hParallelGroup2)
                                .addGap(200).addGroup(hParallelGroup3).addGap(200).addGroup(hParallelGroup4);
                layout_a2.setHorizontalGroup(hGroup2);
                // 垂直组
                GroupLayout.SequentialGroup vSequentialGroup = layout_a2.createSequentialGroup().addComponent(Pool)
                                .addComponent(Pool_i);
                GroupLayout.SequentialGroup vSequentialGroup2 = layout_a2.createSequentialGroup().addComponent(l_当前轮数)
                                .addComponent(l_当前轮数value);
                GroupLayout.SequentialGroup vSequentialGroup3 = layout_a2.createSequentialGroup().addComponent(l_备用);
                GroupLayout.ParallelGroup vGroup2 = layout_a2.createParallelGroup().addGroup(vSequentialGroup)
                                .addGap(200).addGroup(vSequentialGroup2).addGap(200).addGroup(vSequentialGroup3);
                layout_a2.setVerticalGroup(vGroup2);

                /* 设置panel_a3的布局 */
                GroupLayout layout_a3 = new GroupLayout(panel_a3);
                panel_a3.setLayout(layout_a3);
                layout_a3.setAutoCreateContainerGaps(true);
                layout_a3.setAutoCreateGaps(true);
                // 水平组
                GroupLayout.ParallelGroup hParallelGroup_a2 = layout_a3.createParallelGroup().addComponent(YourMoney)
                                .addComponent(YourMoney_i);
                GroupLayout.ParallelGroup hParallelGroup5 = layout_a3.createParallelGroup().addComponent(l_已投注额)
                                .addComponent(l_已投money);
                GroupLayout.ParallelGroup hParallelGroup6 = layout_a3.createParallelGroup().addComponent(l_应投注额)
                                .addComponent(l_应投money);
                GroupLayout.SequentialGroup hGroup3 = layout_a3.createSequentialGroup().addGroup(hParallelGroup_a2)
                                .addGap(175).addGroup(hParallelGroup5).addGap(175).addGroup(hParallelGroup6);
                layout_a3.setHorizontalGroup(hGroup3);
                // 垂直组
                GroupLayout.SequentialGroup vSequentialGroup_a2 = layout_a3.createSequentialGroup()
                                .addComponent(YourMoney).addComponent(YourMoney_i);
                GroupLayout.SequentialGroup vSequentialGroup4 = layout_a3.createSequentialGroup().addComponent(l_已投注额)
                                .addComponent(l_已投money);
                GroupLayout.SequentialGroup vSequentialGroup5 = layout_a3.createSequentialGroup().addComponent(l_应投注额)
                                .addComponent(l_应投money);
                GroupLayout.ParallelGroup vGroup3 = layout_a3.createParallelGroup().addGroup(vSequentialGroup_a2)
                                .addGap(175).addGroup(vSequentialGroup4).addGap(175).addGroup(vSequentialGroup5);
                layout_a3.setVerticalGroup(vGroup3);

                /* 设置panel_a4的布局 */
                GroupLayout layout_a4 = new GroupLayout(panel_a4);
                panel_a4.setLayout(layout_a4);
                layout_a4.setAutoCreateContainerGaps(true);
                layout_a4.setAutoCreateGaps(true);
                // 水平组
                GroupLayout.SequentialGroup hParallelGroup_a6 = layout_a4.createSequentialGroup()
                                .addComponent(YourKicker).addComponent(YourType);
                GroupLayout.SequentialGroup hSequentialGroup2 = layout_a4.createSequentialGroup()
                                .addComponent(kickerC_1).addComponent(kickerC_2);
                GroupLayout.ParallelGroup hGroup4 = layout_a4.createParallelGroup().addGroup(hParallelGroup_a6)
                                .addGroup(hSequentialGroup2);
                layout_a4.setHorizontalGroup(hGroup4);
                // 垂直组
                GroupLayout.ParallelGroup vSequentialGroup_a5 = layout_a4.createParallelGroup().addComponent(YourKicker)
                                .addComponent(YourType);
                GroupLayout.ParallelGroup vParallelGroup3 = layout_a4.createParallelGroup().addComponent(kickerC_1)
                                .addComponent(kickerC_2);
                GroupLayout.SequentialGroup vGroup4 = layout_a4.createSequentialGroup().addGroup(vSequentialGroup_a5)
                                .addGroup(vParallelGroup3);
                layout_a4.setVerticalGroup(vGroup4);

                /* 设置panelA的布局 */
                // 设置4行1列的网格布局
                GridLayout layoutA = new GridLayout(4, 1);
                panelA.setLayout(layoutA);
                // 设置水平和竖直间隔
                layoutA.setHgap(10);
                layoutA.setVgap(10);
                panelA.add(panel_a1);
                panelA.add(panel_a2);
                panelA.add(panel_a3);
                panelA.add(panel_a4);
                /* 设置panelB的布局 */
                GroupLayout layoutB = new GroupLayout(panelB);
                panelB.setLayout(layoutB);
                layoutB.setAutoCreateContainerGaps(true);
                layoutB.setAutoCreateGaps(true);
                // 水平组
                GroupLayout.ParallelGroup hAllHParallelGroup_B = layoutB.createParallelGroup()
                                .addComponent(button_弃牌, GroupLayout.Alignment.CENTER)
                                .addComponent(button_跟注, GroupLayout.Alignment.CENTER)
                                .addComponent(button_加注, GroupLayout.Alignment.CENTER)
                                .addComponent(textField_加注, GroupLayout.Alignment.CENTER)
                                .addComponent(button_继续, GroupLayout.Alignment.CENTER);
                layoutB.setHorizontalGroup(hAllHParallelGroup_B);
                // 垂直组
                GroupLayout.SequentialGroup vAllHParallelGroup_B = layoutB.createSequentialGroup()
                                .addComponent(button_弃牌).addComponent(button_跟注).addComponent(button_加注)
                                .addComponent(textField_加注).addComponent(button_继续);
                layoutB.setVerticalGroup(vAllHParallelGroup_B);

                /* 设置panel_c1的布局 */
                GroupLayout layout_c1 = new GroupLayout(panel_c1);
                panel_c1.setLayout(layout_c1);
                layout_c1.setAutoCreateContainerGaps(true);
                layout_c1.setAutoCreateGaps(true);
                // 水平组
                GroupLayout.ParallelGroup hParallelGroup7 = layout_c1.createParallelGroup().addComponent(PlayerX)
                                .addComponent(PlayerX_i).addComponent(XMoney).addComponent(XMoney_i)
                                .addComponent(l_X玩家牌型);
                GroupLayout.SequentialGroup hSequentialGroup3 = layout_c1.createSequentialGroup()
                                .addComponent(jl_pXCard_1).addComponent(jl_pXCard_2);
                GroupLayout.SequentialGroup hGroup5 = layout_c1.createSequentialGroup().addGroup(hParallelGroup7)
                                .addGroup(hSequentialGroup3);
                layout_c1.setHorizontalGroup(hGroup5);

                // 垂直组
                GroupLayout.SequentialGroup vSequentialGroup6 = layout_c1.createSequentialGroup().addComponent(PlayerX)
                                .addComponent(PlayerX_i).addComponent(XMoney).addComponent(XMoney_i)
                                .addComponent(l_X玩家牌型);
                GroupLayout.ParallelGroup vParallelGroup4 = layout_c1.createParallelGroup().addComponent(jl_pXCard_1)
                                .addComponent(jl_pXCard_2);
                GroupLayout.ParallelGroup vGroup5 = layout_c1.createParallelGroup().addGroup(vSequentialGroup6)
                                .addGroup(vParallelGroup4);
                layout_c1.setVerticalGroup(vGroup5);
                /* 设置panel_c2的布局 */
                GroupLayout layout_c2 = new GroupLayout(panel_c2);
                panel_c2.setLayout(layout_c2);
                layout_c2.setAutoCreateContainerGaps(true);
                layout_c2.setAutoCreateGaps(true);
                // 水平组
                GroupLayout.ParallelGroup hParallelGroup8 = layout_c2.createParallelGroup().addComponent(PlayerY)
                                .addComponent(PlayerY_i).addComponent(YMoney).addComponent(YMoney_i);
                GroupLayout.SequentialGroup hSequentialGroup4 = layout_c2.createSequentialGroup()
                                .addComponent(jl_pYCard_1).addComponent(jl_pYCard_2);
                GroupLayout.ParallelGroup hParallelGroup9 = layout_c2.createParallelGroup().addGroup(hParallelGroup8)
                                .addGroup(hSequentialGroup4).addComponent(l_Y玩家牌型);
                layout_c2.setHorizontalGroup(hParallelGroup9);
                // 垂直组
                GroupLayout.SequentialGroup vSequentialGroup7 = layout_c2.createSequentialGroup().addComponent(PlayerY)
                                .addComponent(PlayerY_i).addComponent(YMoney).addComponent(YMoney_i);
                GroupLayout.ParallelGroup vParallelGroup5 = layout_c2.createParallelGroup().addComponent(jl_pYCard_1)
                                .addComponent(jl_pYCard_2);
                GroupLayout.SequentialGroup vGroup6 = layout_c2.createSequentialGroup().addGroup(vSequentialGroup7)
                                .addGroup(vParallelGroup5).addComponent(l_Y玩家牌型);
                layout_c2.setVerticalGroup(vGroup6);

                /* 设置panel_c3的布局 */
                GroupLayout layout_c3 = new GroupLayout(panel_c3);
                panel_c3.setLayout(layout_c3);
                layout_c3.setAutoCreateContainerGaps(true);
                layout_c3.setAutoCreateGaps(true);
                // 水平组
                GroupLayout.ParallelGroup hParallelGroup10 = layout_c3.createParallelGroup().addComponent(PlayerZ)
                                .addComponent(PlayerZ_i).addComponent(ZMoney).addComponent(ZMoney_i)
                                .addComponent(l_Z玩家牌型);
                GroupLayout.SequentialGroup hSequentialGroup5 = layout_c3.createSequentialGroup()
                                .addComponent(jl_pZCard_1).addComponent(jl_pZCard_2);
                GroupLayout.SequentialGroup hGroup6 = layout_c3.createSequentialGroup().addGroup(hParallelGroup10)
                                .addGroup(hSequentialGroup5);
                layout_c3.setHorizontalGroup(hGroup6);
                // 垂直组
                GroupLayout.SequentialGroup vSequentialGroup8 = layout_c3.createSequentialGroup().addComponent(PlayerZ)
                                .addComponent(PlayerZ_i).addComponent(ZMoney).addComponent(ZMoney_i)
                                .addComponent(l_Z玩家牌型);
                GroupLayout.ParallelGroup vParallelGroup6 = layout_c3.createParallelGroup().addComponent(jl_pZCard_1)
                                .addComponent(jl_pZCard_2);
                GroupLayout.ParallelGroup vGroup7 = layout_c3.createParallelGroup().addGroup(vSequentialGroup8)
                                .addGroup(vParallelGroup6);
                layout_c3.setVerticalGroup(vGroup7);

                /* 设置panelD的布局 */
                GridLayout layoutD = new GridLayout(1, 1);
                panelD.setLayout(layoutD);
                panelD.add(jl_bg_image);

                /* 设置panelC的布局 */
                BorderLayout layoutC = new BorderLayout();
                panelC.setLayout(layoutC);
                panelC.add(panel_c1, BorderLayout.NORTH);
                panelC.add(panel_c2, BorderLayout.EAST);
                panelC.add(panel_c3, BorderLayout.SOUTH);
                panelC.add(panelD, BorderLayout.CENTER);
                panelC.add(panelB, BorderLayout.WEST);
                /* 设置AllPanel布局 */
                GridLayout AllLayout = new GridLayout(1, 2);
                AllPanel.setLayout(AllLayout);
                // 设置水平和竖直间隔
                AllLayout.setHgap(10);
                AllLayout.setVgap(10);
                AllPanel.add(panelA);
                AllPanel.add(panelC);
                // AllPanel.add(bg_image);
                // JLayeredPane layeredPane = new JLayeredPane();
                // layeredPane.add(AllPanel, 0, 0);
                /*
                 * JPanel bgjp = new JPanel(); ImageIcon bgimg = new
                 * ImageIcon(".\\image\\poker\\" + "00" + ".png"); JLabel bglb = new
                 * JLabel(bgimg); bgjp.add(bglb); layeredPane.add(bgjp, 0);
                 */
                // 细节设置
                // window.setContentPane(layeredPane);
                window.setContentPane(AllPanel);
                // window.pack();
                window.setLocationRelativeTo(null);
                int money = 100;
                for (int count = 1; count <= 8; count++) {
                        l_当前轮数value.setText("第" + count + "轮/共8轮");
                        publicC_1.setIcon(new ImageIcon(".\\image\\poker\\" + "00" + ".png"));
                        publicC_2.setIcon(new ImageIcon(".\\image\\poker\\" + "00" + ".png"));
                        publicC_3.setIcon(new ImageIcon(".\\image\\poker\\" + "00" + ".png"));
                        publicC_4.setIcon(new ImageIcon(".\\image\\poker\\" + "00" + ".png"));
                        publicC_5.setIcon(new ImageIcon(".\\image\\poker\\" + "00" + ".png"));
                        jl_pXCard_1.setIcon(new ImageIcon(".\\image\\poker\\" + "00" + ".png"));
                        jl_pXCard_2.setIcon(new ImageIcon(".\\image\\poker\\" + "00" + ".png"));
                        jl_pYCard_1.setIcon(new ImageIcon(".\\image\\poker\\" + "00" + ".png"));
                        jl_pYCard_2.setIcon(new ImageIcon(".\\image\\poker\\" + "00" + ".png"));
                        jl_pZCard_1.setIcon(new ImageIcon(".\\image\\poker\\" + "00" + ".png"));
                        jl_pZCard_2.setIcon(new ImageIcon(".\\image\\poker\\" + "00" + ".png"));
                        l_备用.setText(null);
                        YourType.setText(null);
                        l_X玩家牌型.setText(null);
                        l_Y玩家牌型.setText(null);
                        l_Z玩家牌型.setText(null);
                        try {
                                String g = Test.link.readLine();
                                if (g.equals("<game over>")) {
                                        new Gameover();
                                        window.setVisible(false);
                                        return;
                                }
                                turn1(g);
                        } catch (IOException ioe) {
                                ioe.printStackTrace();
                        }
                        while (true) {
                                try {
                                        String str = Test.link.readLine();
                                        if (str.equals("<update>")) {
                                                if (!Test.link.readLine().equals("玩家金额"))
                                                        throw new IOException();
                                                money = Integer.parseInt(Test.link.readLine());
                                                YourMoney_i.setText("$" + money);
                                                XMoney_i.setText("$" + Test.link.readLine());
                                                YMoney_i.setText("$" + Test.link.readLine());
                                                ZMoney_i.setText("$" + Test.link.readLine());

                                                if (!Test.link.readLine().equals("应压注额"))
                                                        throw new IOException();
                                                int needBet = Integer.parseInt(Test.link.readLine());
                                                l_应投money.setText("$" + needBet);

                                                if (!Test.link.readLine().equals("已压注额"))
                                                        throw new IOException();
                                                int bet = Integer.parseInt(Test.link.readLine());
                                                l_已投money.setText("$" + bet);

                                                if (!Test.link.readLine().equals("奖池金额"))
                                                        throw new IOException();
                                                Pool_i.setText("$" + Test.link.readLine());
                                                maxAdd = money - (needBet - bet);// 计算最大加注额
                                                String s = Test.link.readLine();
                                                if (s.equals("当前玩家"))
                                                        l_备用.setText(Test.link.readLine());
                                                else if (!s.equals("本轮结束")) {
                                                        throw new IOException();
                                                }
                                        } else if (str.equals("<your turn2>")) {
                                                button_弃牌.setEnabled(true);
                                                button_跟注.setEnabled(true);
                                                button_加注.setEnabled(false);
                                                textField_加注.setEnabled(false);
                                        } else if (str.equals("<your turn3>")) {
                                                button_弃牌.setEnabled(true);
                                                button_跟注.setEnabled(true);
                                                button_加注.setEnabled(true);
                                                textField_加注.setEnabled(true);
                                        } else if (str.equals("<public>")) {
                                                publicC_1.setIcon(new ImageIcon(
                                                                ".\\image\\poker\\" + Test.link.readLine() + ".png"));
                                                publicC_2.setIcon(new ImageIcon(
                                                                ".\\image\\poker\\" + Test.link.readLine() + ".png"));
                                                publicC_3.setIcon(new ImageIcon(
                                                                ".\\image\\poker\\" + Test.link.readLine() + ".png"));
                                                publicC_4.setIcon(new ImageIcon(
                                                                ".\\image\\poker\\" + Test.link.readLine() + ".png"));
                                                publicC_5.setIcon(new ImageIcon(
                                                                ".\\image\\poker\\" + Test.link.readLine() + ".png"));
                                        } else if (str.equals("<publish>")) {
                                                Test.link.readLine();
                                                Test.link.readLine();
                                                YourType.setText("| 你的牌型: " + Test.link.readLine());
                                                jl_pXCard_1.setIcon(new ImageIcon(
                                                                ".\\image\\poker\\" + Test.link.readLine() + ".png"));
                                                jl_pXCard_2.setIcon(new ImageIcon(
                                                                ".\\image\\poker\\" + Test.link.readLine() + ".png"));
                                                l_X玩家牌型.setText(Test.link.readLine());
                                                jl_pYCard_1.setIcon(new ImageIcon(
                                                                ".\\image\\poker\\" + Test.link.readLine() + ".png"));
                                                jl_pYCard_2.setIcon(new ImageIcon(
                                                                ".\\image\\poker\\" + Test.link.readLine() + ".png"));
                                                l_Y玩家牌型.setText(Test.link.readLine());
                                                jl_pZCard_1.setIcon(new ImageIcon(
                                                                ".\\image\\poker\\" + Test.link.readLine() + ".png"));
                                                jl_pZCard_2.setIcon(new ImageIcon(
                                                                ".\\image\\poker\\" + Test.link.readLine() + ".png"));
                                                l_Z玩家牌型.setText(Test.link.readLine());
                                                l_备用.setText(Test.link.readLine());// 胜利玩家信息
                                        } else if (str.equals("<round end>")) {
                                                button_弃牌.setEnabled(false);
                                                button_加注.setEnabled(false);
                                                button_跟注.setEnabled(false);
                                                textField_加注.setEnabled(false);
                                                button_继续.setEnabled(money != 0);
                                        } else if (str.equals("<new game>")) {
                                                break;
                                        } else {
                                                throw new IOException("非法命令");
                                        }
                                } catch (IOException ioe) {
                                        ioe.printStackTrace();
                                }
                        }
                }
        }

        private void turn1(String g) {
                // 接收起脚牌
                try {
                        if (!g.equals("起脚牌"))
                                throw new IOException();
                        int kicker_1_value = Integer.parseInt(Test.link.readLine());
                        int kicker_2_value = Integer.parseInt(Test.link.readLine());
                        if (kicker_1_value > kicker_2_value) {
                                int temp = kicker_1_value;
                                kicker_1_value = kicker_2_value;
                                kicker_2_value = temp;
                        }
                        kickerC_1.setIcon(new ImageIcon(getImgPath(kicker_1_value)));
                        kickerC_2.setIcon(new ImageIcon(getImgPath(kicker_2_value)));
                } catch (IOException ioe) {
                        ioe.printStackTrace();
                }
                // 接收玩家金额
                try {
                        if (!Test.link.readLine().equals("玩家金额"))
                                throw new IOException();
                        YourMoney_i.setText('$' + Test.link.readLine());
                        XMoney_i.setText('$' + Test.link.readLine());
                        YMoney_i.setText('$' + Test.link.readLine());
                        ZMoney_i.setText('$' + Test.link.readLine());
                } catch (IOException ioe) {
                        ioe.printStackTrace();
                }
                // 接收玩家昵称及身份
                try {
                        if (!Test.link.readLine().equals("玩家昵称及身份"))
                                throw new IOException();
                        YourKicker.setText("您的起脚牌：    昵称：" + Test.link.readLine()
                                        + ((Test.link.readLine().equals("true")) ? "      庄家" : ""));
                        PlayerX_i.setText(Test.link.readLine());
                        PlayerX.setText("玩家X：" + ((Test.link.readLine().equals("true")) ? "庄家" : ""));
                        PlayerY_i.setText(Test.link.readLine());
                        PlayerY.setText("玩家Y：" + ((Test.link.readLine().equals("true")) ? "庄家" : ""));
                        PlayerZ_i.setText(Test.link.readLine());
                        PlayerZ.setText("玩家Z：" + ((Test.link.readLine().equals("true")) ? "庄家" : ""));
                } catch (IOException ioe) {
                        ioe.printStackTrace();
                }
        }

        private static String getImgPath(int i) {
                return ".\\image\\poker\\" + i + ".png";
        }

        public void actionPerformed(ActionEvent e) {
                if (e.getSource() == button_弃牌) {
                        Test.link.println("1");
                } else if (e.getSource() == button_跟注) {
                        Test.link.println("2");
                } else if (e.getSource() == button_加注) {
                        if (textField_加注.getText().isEmpty()) {
                                return;
                        }
                        try {
                                int add = Integer.parseInt(textField_加注.getText());
                                if (add <= 0 || add > maxAdd) {
                                        throw new NumberFormatException();
                                }
                                Test.link.println("3");
                                Test.link.println(Integer.toString(add));
                        } catch (NumberFormatException nfe) {
                                return;
                        }
                } else if (e.getSource() == button_继续) {
                        Test.link.println("<continue>");
                }
                button_弃牌.setEnabled(false);
                button_加注.setEnabled(false);
                button_跟注.setEnabled(false);
                textField_加注.setEnabled(false);
                button_继续.setEnabled(false);
        }
}